package cn.xuewenbao.edu.controller;


import cn.xuewenbao.edu.service.ViewContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-09-06
 */
@RestController
@RequestMapping("/edu/view-content")
@Api(tags = "阅读表")
public class ViewContentController {

    @Autowired
    private ViewContentService viewContentService;

    //得到该作者的昨天的阅读量
    @ApiOperation("得到该作者的昨天的阅读量")
    @GetMapping("getLastViewCount/{userId}")
    public Result<Map<String, Long>> getLastViewCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = viewContentService.getLastViewCount(userId);
        return result;
    }

    //得到该作者的一周的阅读量
    @ApiOperation("得到该作者的一周的阅读量")
    @GetMapping("getWeekViewCount/{userId}")
    public Result<Map<String, Long>> getWeekViewCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = viewContentService.getWeekViewCount(userId);
        return result;
    }

    //得到该作者的一月的阅读量
    @ApiOperation("得到该作者的一月的阅读量")
    @GetMapping("getMonthViewCount/{userId}")
    public Result<Map<String, Long>> getMonthViewCount(@PathVariable String userId) {
        Result<Map<String, Long>> result = viewContentService.getMonthViewCount(userId);
        return result;
    }

    //得到该作者总阅读量
    @ApiOperation("得到该作者总阅读量")
    @GetMapping("getTotalViewCount/{userId}")
    public Result<Integer> getTotalViewCount(@PathVariable String userId){
        Result<Integer> result = viewContentService.getTotalViewCount(userId);
        return result;
    }

}

